home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / src / NewGroup.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  5.6 KB  |  197 lines

  1. #include "includes.h"
  2. #include "globals.h"
  3. #include "htmlgad.h"
  4. #include "NewGroup.h"
  5.  
  6. typedef struct opSet * opSetP;
  7. typedef struct opGet * opGetP;
  8.  
  9. struct NewGroupData
  10. {
  11.     ULONG    NewLeft,NewTop;
  12.     ULONG    NewWidth,NewHeight;
  13.     ULONG    InitialLeft,InitialTop;
  14.     ULONG    ChildWidth,ChildHeight;
  15. };
  16.  
  17. long kprintf(char *,...);
  18.  
  19. __saveds ULONG NewGroupSet(struct IClass *cl,Object *obj,Msg msg)
  20. {
  21.     struct NewGroupData *inst=INST_DATA(cl,obj);
  22.     struct TagItem *tstate, *ti;
  23.   
  24.     ti = ((opSetP)msg)->ops_AttrList;
  25.     tstate = ti;
  26.   
  27.     while (ti = NextTagItem(&tstate)) {
  28.     switch (ti->ti_Tag) {
  29.         case MUIA_NewGroup_Left: inst->NewLeft=ti->ti_Data; break;
  30.         case MUIA_NewGroup_Top:  inst->NewTop=ti->ti_Data; break;
  31.         }
  32.     }
  33.     return DoSuperMethodA(cl, obj, msg);
  34. }
  35.  
  36. __saveds ULONG NewGroupGet(struct IClass *cl,Object *obj,Msg msg)
  37. {
  38.     struct NewGroupData *inst=INST_DATA(cl,obj);
  39.     struct TagItem *tstate, *ti;
  40.   
  41.     switch (((opGetP)msg)->opg_AttrID) {
  42.         case MUIA_NewGroup_Left:   *(((opGetP)msg)->opg_Storage) = (ULONG)(inst->NewLeft); break;
  43.         case MUIA_NewGroup_Top:    *(((opGetP)msg)->opg_Storage) = (ULONG)(inst->NewTop); break;
  44.         case MUIA_NewGroup_Width:  *(((opGetP)msg)->opg_Storage) = (ULONG)(inst->NewWidth); break;
  45.         case MUIA_NewGroup_Height: *(((opGetP)msg)->opg_Storage) = (ULONG)(inst->NewHeight); break;
  46.         }
  47.     return DoSuperMethodA(cl, obj, msg);
  48. }
  49.  
  50. __saveds ULONG NewGroupNew(struct IClass *cl,Object *obj,Msg msg)
  51. {
  52.     struct NewGroupData *inst;
  53.     if (!(obj= (Object *)DoSuperMethodA(cl,obj,msg)))
  54.         return 0L;
  55.  
  56.     inst = INST_DATA(cl, obj);
  57.  
  58.     inst->NewWidth    = GetTagData(MUIA_NewGroup_Width, NULL,((opSetP)msg)->ops_AttrList);
  59.     inst->NewHeight   = GetTagData(MUIA_NewGroup_Height, NULL,((opSetP)msg)->ops_AttrList);
  60.  
  61.     inst->NewLeft     = GetTagData(MUIA_NewGroup_Left, 0x80000000,((opSetP)msg)->ops_AttrList);
  62.     inst->NewTop      = GetTagData(MUIA_NewGroup_Top, 0x80000000,((opSetP)msg)->ops_AttrList);
  63.  
  64.     inst->ChildWidth  = GetTagData(MUIA_NewGroup_ChildWidth, NULL,((opSetP)msg)->ops_AttrList);
  65.     inst->ChildHeight = GetTagData(MUIA_NewGroup_ChildHeight, NULL,((opSetP)msg)->ops_AttrList);
  66.  
  67.     inst->InitialLeft = 0x80000000;
  68.     inst->InitialTop  = 0x80000000;
  69.  
  70.     return (ULONG)obj;
  71. }
  72.  
  73. __saveds ULONG NewGroupAskMinMax(struct IClass *cl,Object *obj,struct MUIP_AskMinMax *msg)
  74. {
  75.     struct NewGroupData *inst = INST_DATA(cl, obj);
  76.  
  77.     DoSuperMethodA(cl,obj,(Msg)msg);
  78.  
  79.     if(inst->NewWidth){
  80.         msg->MinMaxInfo->MinWidth  = inst->NewWidth;
  81.         msg->MinMaxInfo->DefWidth  = inst->NewWidth;
  82.         msg->MinMaxInfo->MaxWidth  = inst->NewWidth;
  83.     }
  84.     if(inst->NewHeight){
  85.         msg->MinMaxInfo->MinHeight = inst->NewHeight;
  86.         msg->MinMaxInfo->DefHeight = inst->NewHeight;
  87.         msg->MinMaxInfo->MaxHeight = inst->NewHeight;
  88.     }
  89.  
  90.     if(inst->ChildWidth){
  91.         msg->MinMaxInfo->MinWidth  = msg->MinMaxInfo->DefWidth;
  92.         msg->MinMaxInfo->MaxWidth  = msg->MinMaxInfo->DefWidth;
  93.         inst->NewWidth = msg->MinMaxInfo->DefWidth;
  94.         }
  95.     if(inst->ChildHeight){
  96.         msg->MinMaxInfo->MinHeight = msg->MinMaxInfo->DefHeight;
  97.         msg->MinMaxInfo->MaxHeight = msg->MinMaxInfo->DefHeight;
  98.         inst->NewHeight = msg->MinMaxInfo->DefHeight;
  99.         }
  100.     
  101.  
  102.     return(0);
  103. }
  104.  
  105. __saveds ULONG NewGroupPlaceObject(struct IClass *cl,Object *obj,struct MUIP_PlaceObject *msg)
  106. {
  107.     struct NewGroupData *inst = INST_DATA(cl, obj);
  108.     ULONG res,old_x,old_y,virt_x,virt_y;
  109.  
  110.     if(MUIMasterBase->lib_Version<11)
  111.         {
  112. //        kprintf("GVirt: left: %ld top: %ld\n",virt_x,virt_y);
  113. //        kprintf("Obj: left: %ld top: %ld\n",inst->NewLeft,inst->NewTop);
  114.  
  115.  
  116.     inst->NewWidth=msg->width;
  117.     inst->NewHeight=msg->height;
  118.     if(inst->NewLeft!=0x80000000){
  119.         old_x=msg->x;
  120.         if(inst->InitialLeft==0x80000000){
  121. //            inst->InitialLeft=msg->x;
  122.             msg->x=inst->NewLeft;
  123.             }
  124.         else{
  125.             msg->x=inst->NewLeft+msg->x-inst->InitialLeft;
  126.             }
  127.         }
  128.     if(inst->NewTop!=0x80000000){
  129.         old_y=msg->y;
  130.         if(inst->InitialTop==0x80000000){
  131. //            inst->InitialTop=msg->y;
  132.             msg->y=inst->NewTop;
  133.             }
  134.         else{
  135.             msg->y=inst->NewTop+msg->y-inst->InitialTop;
  136.             }
  137.         }
  138.  
  139.     res=DoSuperMethodA(cl,obj,(Msg)msg);
  140.  
  141.     if(inst->NewLeft!=0x80000000)
  142.         msg->x=old_x;
  143.     if(inst->NewTop!=0x80000000)
  144.         msg->y=old_y;
  145.     return res;
  146.         }
  147.     else
  148.         return DoSuperMethodA(cl,obj,(Msg)msg);
  149. }
  150.  
  151. __saveds ULONG NewGroupLayout(struct IClass *cl,Object *obj,struct MUIP_PlaceObject *msg)
  152. {
  153.     struct NewGroupData *inst = INST_DATA(cl, obj);
  154.  
  155.     if(inst->NewLeft!=0x80000000 && inst->NewTop!=0x80000000){
  156.         inst->NewWidth=_defwidth(obj);
  157.         inst->NewHeight=_defheight(obj);
  158.         MUI_Layout(obj,inst->NewLeft,inst->NewTop,_defwidth(obj),_defheight(obj),0);
  159. //        MUI_Layout(obj,0,0,_defwidth(obj),_defheight(obj),0);
  160.         }
  161. //    kprintf("Placing object at x: %ld y: %ld width: %ld height: %ld\n",inst->NewLeft,inst->NewTop,_defwidth(obj),_defheight(obj));
  162.  
  163.  
  164.     return TRUE;
  165. }
  166.  
  167. __saveds __asm ULONG NewGroupDispatcher(register __a0 struct IClass *cl,register __a2 Object *obj,register __a1 Msg msg)
  168. {
  169.     ULONG res;
  170.     switch (msg->MethodID){
  171.         case OM_NEW              : return(NewGroupNew        (cl,obj,(APTR)msg));
  172.         case MUIM_AskMinMax      : return(NewGroupAskMinMax  (cl,obj,(APTR)msg));
  173.         case MUIM_PlaceObject    : return(NewGroupPlaceObject(cl,obj,(APTR)msg));
  174.         case OM_SET                 : return(NewGroupSet        (cl,obj,(APTR)msg));
  175.         case OM_GET                 : return(NewGroupGet        (cl,obj,(APTR)msg));
  176.         case MUIM_NewGroup_Layout: return(NewGroupLayout     (cl,obj,(APTR)msg));
  177.     }
  178.     return DoSuperMethodA(cl,obj,msg);
  179. }
  180.  
  181. struct MUI_CustomClass *NewGroupClInit(void)
  182. {
  183.   struct MUI_CustomClass *cl;
  184.  
  185.   /* Create the HTML gadget class */
  186.   if (!(cl = MUI_CreateCustomClass(NULL,MUIC_Group,NULL,
  187.                   sizeof(struct NewGroupData),NewGroupDispatcher)))
  188.     fail(NULL, "Failed to create New Group class."); /* Failed, cleanup */
  189.   return cl;
  190. }
  191.  
  192. BOOL NewGroupClFree(struct MUI_CustomClass *mcc)
  193. {
  194.   MUI_DeleteCustomClass(mcc);
  195.   return 0;
  196. }
  197.